package com.sk.netty.udpserver;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioDatagramChannel;

public class EchoUdpServer {

    public static void main(String[] args) throws Exception{
        new EchoUdpServer().start();
    }
    public void start() throws Exception{
        final EchoUdpServerHandlerIn in = new EchoUdpServerHandlerIn();
        EventLoopGroup eventLoopGroup = new NioEventLoopGroup(3);

        try {
            Bootstrap server = new Bootstrap();
            server.group(eventLoopGroup)
                    .channel(NioDatagramChannel.class)
                    .handler(in);
            ChannelFuture future = server.bind(19090).sync();

            future.channel().closeFuture().await();


        }finally {
            eventLoopGroup.shutdownGracefully().sync();
        }


    }

}
